public class TestDemo {
    public static String myToString(int[] array){
        String ret = "[";
        for (int i = 0; i < array.length; i++) {
            ret += array[i];//不建议在循环里用String进行拼接，最好的方式是使用StringBuilder或StringBuffer
            //ret = ret + array[i];
            if (i != array.length-1) {
                ret += ",";
            }
        }
        ret += "]";
        return ret;
    }
    public static void main1(String[] args) {
        int[] array = {1,2,3,4};
        String ret = myToString(array);
        System.out.println(ret);//[1,2,3,4]

    }
}
